<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<style type="text/css">
.backcolor{
background-color: #5cacee;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="../header.jsp"></jsp:include>
<title>用户信息</title>
</head>
<body>
<div class="contextBox" >



 




<form name="form" action="<%=request.getContextPath()%>/riskManage/getrisklist.do.do?currentPage=1" method="post">

        <ul class="tabs">
			<li><a href="#" name=".tab1_1"  onclick="saveCSinfo('1')">添加催记</a></li>
			<li><a href="#"  name=".tab1_2" onclick="sendMessage('1')">发送短信</a></li>
			<li><a href="#"  name=".tab1_3" onclick="replaySavecase('1')">申请留案</a></li>
			<select  id="caseflge" style="float:right;width: 100px;background-color:#000000;color: #FFFFFF; ">
			  <c:forEach var="kf" items="${caselist}">
		       <option id="case_${kf.id}" value="${kf.key}" <c:if test="${kf.key=='3' || kf.key=='9' }"> style="color: red"</c:if> <c:if test="${kf.key=='14' || kf.key=='28' }"> style="color: green"</c:if>>${kf.value}</option>
			   </c:forEach>
		       </select>
			
		</ul>
		
		<div class="content">
		<div class="tab1_1">
				<table width="100%" class="TableList" border="1px">
					<tbody>
						<tr class="TableHeader">
							<td>
							号码：<input id="csuserphone" type="text" />
							拨打结果：<select id="callcontentm">
			                        <c:forEach var="ph" items="${phonelist}">
		                            <option id="phone_${ph.id}" value="${ph.key}" >${ph.value}</option>
			                        </c:forEach>
		                            </select>
							</td>
							
						</tr>
						<tr class="TableHeader">
							<td>
							关系：<input id="relation" type="text" />
							姓名：<input id="relationname" type="text" />
							</td>
							
						</tr>
						<tr class="TableHeader">
							<td>
							记录：<textarea id="cscontent"></textarea>
							
							</td>
							
						</tr>
						<tr class="TableHeader">
							<td>
							<input type="button" onclick="saveCSinfo('2')" value="添加催记"/>
							</td>
							
						</tr>
						 
                   </tbody>
				</table>
		<table id="userinfotable" class="table" width="100%" align="center" border="0" cellspacing="0" cellpadding="0" class="list_table">
	    <tbody>
	    <tr>
	    <th width="20%" class="list_title" align="center"><b>催收时间</b></th>
		<th width="7%" class="list_title" align="center"><b>电话号码</b></th>
		<th width="8%" class="list_title" align="center"><b>拨打结果</b></th>
		<th width="10%" class="list_title" align="center"><b>客户姓名</b></th>
		<th width="10%" class="list_title" align="center"><b>关系</b></th>
		<th width="14%" class="list_title" align="center"><b>备注</b></th>
	    </tr>
		<tbody id="investbody">
		
		</tbody>
	  
	
	      </tbody>
	     </table>
				
			</div>
		<div class="tab1_2">
		<table width="100%" class="TableList" border="1px">
					<tbody>
						<tr class="TableHeader">
							<td>
							短信模板：<select id="messageMode" style="width: 180px">
			                        <c:forEach var="ms" items="${messagelist}">
		                            <option id="message_${ms.id}" value="${ms.key}" zdyattr="${ms.demomessage }"  >${ms.value}</option>
			                        </c:forEach>
		                            </select>
							<input  id="userphone" type="text" style="width: 20%" placeholder="输入手机号码（最多4个号码，号码之间用用',')隔开"/>
							</td>
							
						</tr>
						<tr>
						<td>
						<div >
						<textarea id="showmessageinfo" rows="3" cols="100"></textarea>
						</div>
						</td>
						</tr>
						<tr class="TableHeader">
							<td>
							<input type="button" onclick="sendMessage('2')" value="发送短信"/>
							</td>
							
						</tr>
						
                   </tbody>
               </table>
               <table id="userinfotable" class="table" width="100%" align="center" border="0" cellspacing="0" cellpadding="0" class="list_table">
	    <tbody>
	    <tr>
	    <th width="20%" class="list_title" align="center"><b>催收时间</b></th>
		<th width="7%" class="list_title" align="center"><b>短信内容</b></th>
		<th width="8%" class="list_title" align="center"><b>发送时间</b></th>
		<th width="10%" class="list_title" align="center"><b>对方号码</b></th>
		
	    </tr>
			<tbody id="Messagebody">
			</tbody>
		
	 
	
	      </tbody>
	     </table>
               
               
		</div>
		<div class="tab1_3">
		<table width="100%" class="TableList" border="1px">
					<tbody>
						<tr class="TableHeader">
						   <td>
						   申请留案：<select id="replayDays">
						  <option value="7">7天</option>
						  <option value="14">14天</option>
						  <option value="30">30天</option>
						   </select>
						   </td>
							
						</tr>
						<tr class="TableHeader">
						   <td>
						   申请内容：<textarea id="replayContent" rows="" cols=""></textarea>
						   </td>
							
						</tr>
						<tr class="TableHeader">
							<td>
							<input type="button"  onclick="replaySavecase('2')" value="保存"/>
							</td>
							
						</tr>
						
                   </tbody>
				</table>
				
		<table id="userinfotable" class="table" width="100%" align="center" border="0" cellspacing="0" cellpadding="0" class="list_table">
	    <tbody>
	    <tr>
	    <th width="20%" class="list_title" align="center"><b>申请时间</b></th>
		<th width="7%" class="list_title" align="center"><b>申请人</b></th>
		<th width="8%" class="list_title" align="center"><b>申请内容</b></th>
		<th width="8%" class="list_title" align="center"><b>申请天数</b></th>
	    </tr>
		 <tbody id="replaybody">
		 </tbody>
	    </tbody>
	     </table>
		</div>
</div>


<div style="height: 30px"></div>

 <fieldset style="border: 1px solid #C1DAD7;font-size: 12px;padding: 6px 6px 6px 12px;">
    <legend>用户个人基本信息</legend>
        <label id="usernusername"> ${userinfomap.userName }</label>,
        <label> ${userinfomap.sex }</label>,
        <label> ${userinfomap.age }</label>,
        <label> ${userinfomap.userPhone }</label>,
        <label> ${userinfomap.address }</label>
        
  </fieldset>
  <div style="height: 20px"></div>
   <fieldset style="border: 1px solid #C1DAD7;font-size: 12px;padding: 6px 6px 6px 12px;">
    <legend>案件信息</legend>
       【合同金额】 <label> ${orderinfomap.totalmoney }</label>&nbsp; &nbsp; &nbsp;
       【逾期金额】   <label> ${orderinfomap.overdueSumMoney }</label>&nbsp; &nbsp; &nbsp;
       【已还金额】   <label> ${orderinfomap.repayMoney }</label>&nbsp; &nbsp; &nbsp;
       【催收金额】   <label> ${orderinfomap.payMoney }</label>&nbsp; &nbsp; &nbsp;
       【逾期天数】    <label> ${orderinfomap.yqday }</label>
        
  </fieldset>
  <div style="height: 20px"></div>
  <fieldset style="border: 1px solid #C1DAD7;font-size: 12px;padding: 6px 6px 6px 12px;">
    <legend>联系人信息</legend>
       【第一联系人联系方式】<label> ${catamap.RelativesPhoneNo }</label>
      &nbsp; &nbsp; &nbsp;
       【第一联系人姓名】   <label> ${catamap.RelativesName }</label>
         &nbsp; &nbsp; &nbsp;
       【第一联系人关系】  <c:if test="${catamap.directRelatives==1 }">  
       <label> 父母</label>
       </c:if> 
       <c:if test="${catamap.directRelatives==2 }">  
       <label> 配偶</label>
       </c:if>
        <c:if test="${catamap.directRelatives==3 }">  
       <label> 兄弟姐妹</label>
       </c:if> 
    <br>
       【第二联系人联系方式】 <label> ${catamap.friendPhoneNo }</label>  &nbsp; &nbsp; &nbsp;
       【第二联系人姓名】   <label> ${catamap.friendName }</label>  &nbsp; &nbsp; &nbsp;
       【第二联系人关系】   <c:if test="${catamap.friendColleague==1 }">  
       <label> 同学</label>
       </c:if> 
       <c:if test="${catamap.friendColleague==2 }">  
       <label> 同事</label>
       </c:if>
        <c:if test="${catamap.friendColleague==3 }">  
       <label> 朋友</label>
       </c:if> 
       
       <table id="phonepeople" class="table" width="100%" align="center" border="0" cellspacing="0" cellpadding="0" class="list_table">
	    <tbody>
	    <tr>
	    <th width="30%" class="list_title" align="center"><b>联系人备注</b></th>
		<th width="30%" class="list_title" align="center"><b>频繁联系人电话</b></th>
		<th width="30%" class="list_title" align="center"><b>通话时长（分）</b></th>
	    </tr>
		 <tbody id="phoneuserbody">
		 <c:forEach items="${phonedatalist}" var="ui">		
		<tr>
		<td  align="left"><span></span></td>
	    <td  align="right"><span>${ui.call_number }</span></td>
	    <td  align="right"><span><fmt:formatNumber type="number" value="${ui.calltimes}" pattern="#.00"/></span></td>
	    </tr>
	</c:forEach>
		 </tbody>
	    </tbody>
	     </table>
   <!--      <table>
		<tbody>
		<tr>
		<td>
	    <input type="button" name="first1" value="首页" onclick="first()" class="button gray" /> 
			<input type="button" name="pre1" value="上一页" onclick="pre()" class="button green"/> 
			<input type="button" name="next1" value="下一页" onclick="next()" class="button blue"/> 
			<input type="button" name="end1" value="尾页" onclick="end()" class="button gray"/> 
			<font>第<label id="currentPage">1</label>页, 共<label id="pageCount"> </label>页,共<label id="currentPage"> </label>条数据</font>
		</td>
		</tr>
		</tbody>
		</table> -->
  </fieldset>
  
  <table>
  <tr>
  <td>
   <input type="button" value="返回"  onclick="window.history.go(-1);window.location.reload()"/>
   
  </td>
  </tr>
  </table>
 </form>	
</div>
<script type="text/javascript">
var orderno='${orderno}';
var usernumber='${usernumber}';
$(function (){ 
	
	loadTab();
	 var options=$("#messageMode option:selected"); //获取选中的项
     $("#showmessageinfo").text($("#usernusername").text()+","+options.attr("zdyattr")); 
	
     $("#messageMode").change(function(){
    	    var options=$("#messageMode option:selected"); 
    	    $("#showmessageinfo").text($("#usernusername").text()+","+options.attr("zdyattr")); 
    	});
     //标记标签
     $("#caseflge").change(function(){
    	 var options=$("#caseflge option:selected"); 
    	 var caseflag= options.val();
    	 $.ajax({
  		   type: "post",
  		   url: "<%=request.getContextPath()%>/riskManage/caseFlage.do",
  		   data: {"orderno":orderno,"caseflag":caseflag},
  		   success: function(data){
  			 var obj = JSON.parse(data);
  			 alert(obj.recode);
  		   }
  		}); 
 	    
 	   
 	});
     
    $("#pageCount").text('{pageCount}');
    $("#currentPage").text('{currentPage}');
    saveCSinfo('1');
     
});


//发送短信
function sendMessage(sendtype){
	var userphone=$("#userphone").val();
	var messageshow= $("#showmessageinfo").text();
	 $.ajax({
		   type: "post",
		   url: "<%=request.getContextPath()%>/riskManage/sendMeassage.do",
		   data: {"orderno":orderno,"sendtype":sendtype,"userTel":userphone,"smsStr":messageshow},
		   success: function(data){
			 var obj = JSON.parse(data);
			 if(sendtype=='2'){
			 alert(obj.recode);
			 }
			var htmlstr="";
			 for(var i=0;i<obj.resultdata.length;i++){
	        		htmlstr+="<tr class=\"TableData\">"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].opreateTime+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].messageContent+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].opreateTime+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].touserPhone+"</span></td></tr>"
				}
			 $("#Messagebody").html(htmlstr);
		   }
		});  
}

/**
 *保存添加的催记
 */
function saveCSinfo(showtype){
	var csuserphone=$("#csuserphone").val();
	var callcontentm=$("#callcontentm").val();
	var relation=$("#relation").val();
	var relationname=$("#relationname").val();
	var cscontent=$("#cscontent").val();
	 $.ajax({
		   type: "post",
		   url: "<%=request.getContextPath()%>/riskManage/saveCSinfo.do",
		   data: {"showtype":showtype,"orderno":orderno,"csuserphone":csuserphone,"callcontentm":callcontentm,"relation":relation,"relationname":relationname,"cscontent":cscontent},
		   success: function(data){
			 var obj = JSON.parse(data);
			 var htmlstr="";
			 for(var i=0;i<obj.resultdata.length;i++){
	        		htmlstr+="<tr class=\"TableData\">"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].opreateTime+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].bjUserPhone+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].callMessage+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].relationName+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].userrelation+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].remake+
					  "</td></tr>";
	        	 }
			 $("#investbody").html(htmlstr);
		   }
		});  
	
}


/**
 * 申请留案
 */

function replaySavecase(savetype){
	var replayDays=$("#replayDays").val();
	var replayContent= $("#replayContent").val();
	 $.ajax({
		   type: "post",
		   url: "<%=request.getContextPath()%>/riskManage/saveReplay.do",
		   data: {"orderno":orderno,"savetype":savetype,"replayDays":replayDays,"replayContent":replayContent},
		   success: function(data){
			 var obj = JSON.parse(data);
			 var htmlstr="";
			 for(var i=0;i<obj.resultdata.length;i++){
	        		htmlstr+="<tr class=\"TableData\">"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].sqTime+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].sqUser+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].sqContent+"</span></td>"+
					 "<td  align=\"left\"><span>"+obj.resultdata[i].sqDays+"</span></td></tr>"
				}
			 $("#replaybody").html(htmlstr);
		   }
		});  
}


$(function(){init()});
function init() {
	var page = parseInt(document.form.currentPage.value);
	var pageCount = parseInt(document.form.pageCount.value);
	var count=parseInt(document.form.count.value);
	if (page == 1 && pageCount!=1) {
		document.form.pre1.disabled = "disabled";
		return;
	}
	if (page == count && pageCount!=1) {
		document.form.next1.disabled = "disabled";
		return;
	}
	if (pageCount == 1) {
		document.form.pre1.disabled = "disabled";
		document.form.next1.disabled = "disabled";
		document.form.first1.disabled = "disabled";
		document.form.end1.disabled = "disabled";
		return;
	}
} 
</script>
</body>
</html>